package com.xxz.terminal;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;

import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.Fragment;

public class ThirdFragment extends Fragment {

    View contentview;
    Button treehole_start,treehole_like_store,treehole_mine;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        contentview = inflater.inflate(R.layout.fragment_third, container, false);
        treehole_start = contentview.findViewById(R.id.treehole_start);
        treehole_like_store = contentview.findViewById(R.id.treehole_like_store);
        treehole_mine = contentview.findViewById(R.id.treehole_mine);

        treehole_start.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                builder.setTitle("树洞").setMessage("即将开始树洞漫游，请确认").setPositiveButton("好的",new DialogInterface.OnClickListener(){

                    @Override
                    public void onClick(DialogInterface dialog, int which) {

                        Intent intent = new Intent(getActivity(),TreeHoleReadActivity.class);
                        intent.putExtra("index","漫游页面");
                        startActivity(intent);
                    }

                }).setNegativeButton("不了",null);
                builder.create().show();
            }
        });
        //为我喜欢和我的投递两个按钮在打开详情页面时设置标记，以便用同一个页面完成
        treehole_like_store.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(),TreeHoleStoreActivity.class);
                intent.putExtra("index",1);
                startActivity(intent);
            }
        });

        treehole_mine.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(),TreeHoleStoreActivity.class);
                intent.putExtra("index",2);
                startActivity(intent);
            }
        });
        return contentview;
    }
}